home *** CD-ROM | disk | FTP | other *** search
- Path: access4.digex.net!not-for-mail
- From: ell@access4.digex.net (Ell)
- Newsgroups: comp.lang.c++
- Subject: Re: Doesn't work, Why EXACTLY?
- Date: 16 Jan 1996 02:36:33 GMT
- Organization: The Universe
- Message-ID: <4df2vh$q92@news4.digex.net>
- References: <30FA8289.7AD6@bangate.compaq.com>
- NNTP-Posting-Host: access4.digex.net
- X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
-
- Saurabh Dixit (saurabhd@bangate.compaq.com) wrote:
- : class X {
- : };
- : class Y : public X {
- : };
- :
- : class Base {
- : public:
- : void func1(int a);
- : void func2(X* x);
- : };
- :
- : class Derived : public Base {
- : public:
- : void func1(float b);
- : void func2(Y* y);
- : };
- :
- : when I call func2 from a Derived object with a pointer
- : to an X object, i get - "... cannot convert from X to Y...".
- : So looks like compiler looks at method func2() in Derived
- : class. I would think the signature of the call would make
- : it look in Base class.
- : On the lines of func1() i thought it would work.
- : Please note that I don't want func2() to be virtual.
- : I need func2() to do to distinct operations depending on
- : what type of object was fed to it?
-
- What you describe is the standard way C++ works.
-
- The handle/body, and letter/envelope idioms explained in James Coplien's
- Advanced C++ may help you to do what you desire in C++.
-
- Elliott
-